<template>
	<view class="cart-page">
		<home :clickColorIndex="-1"></home>
		<shoppingCart @currentStepN="currentStepFun" @cartTotalN="cartTotalNFun"></shoppingCart>
	</view>
</template>

<script>
	import tableData from '/pages/test1/tableData.js'
	import {
		cart
	} from '../../utils/http_data.js';
	export default {
		data() {
			return {
				currentStep: 0, // 当前步骤，填写订单为步骤1
				cartTotalCountN: 0, // 购物车数量
				orderDataObj: {}, // 订单数据
				cartList: [],
			};
		},
		computed: {

		},
		onLoad(option) {
			console.log('当前页面刷新：', option.step); //打印出上个页面传递的参数。
			// this.id = option;
			if (option && option.step) {
				this.currentStep = option.step;
			}
		},
		mounted() {
			// this.cartfun();
			if (!uni.getStorageSync('login-userinfo')._id) {
				uni.showToast({
					title: '请先登录',
					icon: 'none'
				});
				uni.navigateTo({
					url: '/pages/login/login'
				});
				console.log(11111111111)
			} else {
				console.log(22222222222222)
			}
		},
		methods: {
			//查询右侧所有数据
			// cartfun() {
			// 	// orderByField: 'title,images,param,poster'
			// 	cart('121212').then((data) => {
			// 		console.log('购物车列表数据：：', data)
			// 		// this.products = data.data;

			// 	})
			// },
			cartTotalNFun(val) {
				console.log('购物车数量：',val)
				this.cartTotalCountN = val;
			},
			currentStepFun(val) {
				console.log('00000:', val)
				// uni.navigateTo({
				// 	url: '/pages/shopping/shopping?step=' + val.currentStep
				// });
				this.currentStep = val.currentStep - 0;
				this.cartList = val // 传递过来的数据
				this.totalPrice = val.totalPrice // 总价价格
			},
			fillOrderNFun(val) {
				console.log('000001:', val)
				// uni.navigateTo({
				// 	url: '/pages/shopping/shopping?step=' + val
				// });
				this.currentStep = val - 0;
			},
			orderDataFun(val) { // 提交订单 传递过来的数据
				this.orderDataObj = val;
			},
			ordercanceFun(val) { // 订单取消
				console.log('订单超时已取消')
			}
		}
	};
</script>

<style scoped>
	.cart-page {
		background-color: #F5F5F5;
		min-height: 100%;
	}
</style>